package com.bkpowernode.javaWeb.servlet;

import jakarta.servlet.*;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

public class BServlet extends GenericServlet {
    @Override
    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
        res.setContentType("text/html");
        PrintWriter out=res.getWriter();
        ServletContext application=this.getServletContext();
        out.print("ServletContext对象是："+application);

        //log
        //这个日志记录在 CATALINA_HOME/logs目录下
        application.log("测试log方法");

        application.log("你的年龄当前"+17+"岁，不足18岁",new RuntimeException("年龄非法"));

        //取
        Object userObj=application.getAttribute("userObj");
        out.print(userObj+"</br>");
    }
}
